package edu.scau.hot.service.impl;

import edu.scau.hot.entity.HotCalendar;
import edu.scau.hot.mapper.HotCalendarMapper;
import edu.scau.hot.service.IHotCalendarService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (HotCalendar)表服务实现类
 *
 * @author PaperEasyCode
 * @since 2022-03-02 18:47:51
 */
@Service("hotCalendarService")
public class HotCalendarServiceImpl implements IHotCalendarService{
    @Resource
    private HotCalendarMapper hotCalendarMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param calendarId 主键
     * @return 实例对象
     */
    @Override
    public HotCalendar queryById(Integer calendarId) {
        return this.hotCalendarMapper.queryById(calendarId);
    }

    /**
     * 查询所有数据
     *
     * @param hotCalendar 筛选条件
     * @return 查询结果
     */
    @Override
    public List<HotCalendar> queryAll(HotCalendar hotCalendar) {
        return this.hotCalendarMapper.queryAll(hotCalendar);
    }

    /**
     * 新增数据
     *
     * @param hotCalendar 实例对象
     * @return 实例对象
     */
    @Override
    public HotCalendar insert(HotCalendar hotCalendar) {
        this.hotCalendarMapper.insert(hotCalendar);
        return hotCalendar;
    }

    /**
     * 修改数据
     *
     * @param hotCalendar 实例对象
     * @return 实例对象
     */
    @Override
    public HotCalendar update(HotCalendar hotCalendar) {
        this.hotCalendarMapper.update(hotCalendar);
        return this.queryById(hotCalendar.getCalendarId());
    }

    /**
     * 通过主键删除数据
     *
     * @param calendarId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer calendarId) {
        return this.hotCalendarMapper.deleteById(calendarId) > 0;
    }
}
